package com.dada;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;

public class DadaGetSign {

	private static String getSign(Map<String, Object> requestMap) {
		// 请求参数键值升序排序
		Collection<String> keySet = requestMap.keySet();
		List<String> list = new ArrayList<String>(keySet);
		Collections.sort(list);

		// 拼参数字符串。
		StringBuffer signStr = new StringBuffer();
		for (int i = 0; i < list.size(); i++) {
			String key = list.get(i);
			signStr.append(key + requestMap.get(key));
		}

		// MD5签名并校验
		String sign = DadaMd5.encrypt(DadaConfigure.appSecret + signStr.toString() + DadaConfigure.appSecret);
		return sign.toUpperCase();
	}
}
